package cn.qf;

import cn.qf.singleton.LazySingleton;
import cn.qf.singleton.Singleton;

public class SingltonApp {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        Singleton s3 = Singleton.getInstance();

        // 使用 == 来比较两对象引用时，比较的是该对象的内存地址是否相同，
        // 而非对象的内容
        System.out.println(s1 == s2);
        System.out.println(s1 == s3);

        System.out.println();

        LazySingleton l1 = LazySingleton.getInstance();
        LazySingleton l2 = LazySingleton.getInstance();
        LazySingleton l3 = LazySingleton.getInstance();
        System.out.println(l1 == l2);
        System.out.println(l1 == l3);
    }
}
